package com.gcd;

import android.app.Activity;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;

import com.gcd.R;
import com.gcd.knowledge.PARAMETERS;

public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        UpdateParameter();
    }
    
    public void btnEditKnowledgeClick(View v){
    	Intent iEK = new Intent(this, EditKnowledge.class);
    	startActivity(iEK);
    }
    
    public void btnSolveClick(View v){
    	Intent iSolve = new Intent(this, Solve.class);
    	startActivity(iSolve);
    }
    
	private void UpdateParameter(){
		DatabaseHelper databaseHelper = new DatabaseHelper(this);
		SQLiteDatabase db = databaseHelper.getWritableDatabase();
		
		Cursor cur = null;
	
		// Kolom-Kolom yang akan diambil
		String[] Colmn = new String[]{"id","nama","nilai"};
		cur = db.query("relasi", Colmn, null, null, null, null, null);
		cur.moveToFirst();
		System.out.println(cur.getCount());
		for(int i=1; i<= cur.getCount(); i++){
			if(i == 1){
				PARAMETERS.PEREMPUAN_SATU = cur.getFloat(2);
				System.out.println(PARAMETERS.PEREMPUAN_SATU);
			}else if(i == 2){
				PARAMETERS.PEREMPUAN_N = cur.getFloat(2);
				System.out.println(PARAMETERS.PEREMPUAN_N);
			}else if(i == 3){
				PARAMETERS.LAKI_LAKI = cur.getFloat(2);
				System.out.println(PARAMETERS.LAKI_LAKI);
			}else if(i == 4){
				PARAMETERS.PEREMPUAN = cur.getFloat(2);
				System.out.println(PARAMETERS.PEREMPUAN);
			}else if(i == 5){
				PARAMETERS.ISTRI_HAS_ANAK_YA = cur.getFloat(2);
				System.out.println(PARAMETERS.ISTRI_HAS_ANAK_YA);
			}else if(i == 6){
				PARAMETERS.ISTRI_HAS_ANAK_TIDAK = cur.getFloat(2);
				System.out.println(PARAMETERS.ISTRI_HAS_ANAK_TIDAK);
			}else if(i == 7){
				PARAMETERS.SUAMI_HAS_ANAK_YA = cur.getFloat(2);
				System.out.println(PARAMETERS.SUAMI_HAS_ANAK_YA);
			}else if(i == 8){
				PARAMETERS.SUAMI_HAS_ANAK_TIDAK = cur.getFloat(2);
				System.out.println(PARAMETERS.SUAMI_HAS_ANAK_TIDAK);
			}else if(i == 9){
				PARAMETERS.AYAH_HAS_IBU_HAS = cur.getFloat(2);
				System.out.println(PARAMETERS.AYAH_HAS_IBU_HAS);
			}else if(i == 10){
				PARAMETERS.AYAH_HAS_IBU_HASNOT = cur.getFloat(2);
				System.out.println(PARAMETERS.AYAH_HAS_IBU_HASNOT);
			}else if(i == 11){
				PARAMETERS.AYAH_HASNOT_IBU_HAS = cur.getFloat(2);
				System.out.println(PARAMETERS.AYAH_HASNOT_IBU_HAS);
			}else if(i == 12){
				PARAMETERS.AYAH_HAS_IBU_HAS_SAUDARA_HAS = cur.getFloat(2);
				System.out.println(PARAMETERS.AYAH_HAS_IBU_HAS_SAUDARA_HAS);
			}else if(i == 13){
				PARAMETERS.AYAH_HASNOT_IBU_HAS_SAUDARA_HAS = cur.getFloat(2);
				System.out.println(PARAMETERS.AYAH_HASNOT_IBU_HAS_SAUDARA_HAS);
			}else if(i == 14){
				PARAMETERS.AYAH_HAS_IBU_HAS_SAUDARA_HASNOT = cur.getFloat(2);
				System.out.println(PARAMETERS.AYAH_HAS_IBU_HAS_SAUDARA_HASNOT);
			}else if(i == 15){
				PARAMETERS.AYAH_HASNOT_IBU_HAS_SAUDARA_HASNOT = cur.getFloat(2);
				System.out.println(PARAMETERS.AYAH_HASNOT_IBU_HAS_SAUDARA_HASNOT);
			}
			cur.moveToNext();
		}
		
		db.close();
	}
}